草庐IT

c++ - yaml-cpp 0.5.1 的可选 key

全部标签

go - 尝试将 yaml 数据转换为结构时输出为空

这个问题在这里已经有了答案:GoUnmarshalingYAMLintostruct(2个答案)关闭4年前。我正在尝试将yaml数据转换为结构并打印它。我得到的这个程序的输出是空的。packagemainimport("fmt""gopkg.in/yaml.v2")typeexamplestruct{variable1stringvariable2string}funcmain(){varaexampleyaml.Unmarshal([]byte("variable1:asd\nvariable2:sdcs"),&a)fmt.Println(a.variable1)}

go - 解析 yaml 结构错误

我有以下yaml,当我尝试解析它时出现错误,知道这里可能遗漏了什么吗?我不确定如何构造区域属性。T他是有效的yamlhttps://codebeautify.org/yaml-validator/cb42f23a错误:errorinmodelextConfigYaml:*yaml:line4:mappingvaluesarenotallowedinthiscontexttypeExternalConfigstruct{Landscapezone`yaml:"Landscape"`}typezonestruct{zonemodels`yaml:"zone"`}typemodelsstru

go - 我们可以参数化 glide.yaml 文件吗?

这是官方文档中的glide.yaml文件package:github.com/Masterminds/glidehomepage:https://masterminds.github.io/glidelicense:MITowners:-name:MattButcheremail:technosophos@gmail.comhomepage:http://technosophos.com-name:MattFarinaemail:matt@mattfarina.comhomepage:https://www.mattfarina.comignore:-appengineexcludeD

go - 如何创建用 golang sciter 库编写的程序的 snap YAML 文件?

你能帮帮我吗?如何为使用名为golang和sciter库的语言编写的golang应用程序创建YAML文件https://sciter.com/?我的意思是如何将内容写入yaml文件以使snapcraft商店的snap正常工作?感谢您的任何建议。packagemainimport("log""github.com/sciter-sdk/go-sciter""github.com/sciter-sdk/go-sciter/window")funcmain(){w,err:=window.New(sciter.SW_TITLEBAR|sciter.SW_RESIZEABLE|sciter.S

go - context 在使用 Value(key) 后返回 nil 接口(interface)

我有一个ctx(context.Context)变量,它的值为:ctx=context.Background.WithCancel.WithCancel.WithValue(peer.peerKey{},&peer.Peer{Addr:(*net.UnixAddr)(0xc000270820),AuthInfo:credentials.AuthInfo(nil)}).WithValue(metadata.mdIncomingKey{},metadata.MD{":authority":[]string{"unix:///run/containerd/containerd.sock"},

go - 主机 key 不匹配

我正在尝试使用Go连接到远程服务器。这就是我正在使用的:(SSHHandshakecomplainsaboutmissinghostkey)key,err:=ioutil.ReadFile("/Users/pankaj/.ssh/id_rsa")iferr!=nil{log.Fatalf("unabletoreadprivatekey:%v",err)}//CreatetheSignerforthisprivatekey.signer,err:=ssh.ParsePrivateKey(key)iferr!=nil{log.Fatalf("unabletoparseprivatekey:

go - Viper 在解码时不考虑我的结构中的 yaml 标签

当我使用viper的Unmarshal方法用我的yaml文件中的值填充我的配置结构时,一些结构字段变成了空!我是这样做的:viper.SetConfigType("yaml")viper.SetConfigName("config")viper.AddConfigPath("/etc/myapp/")viper.AddConfigPath(".")err:=viper.ReadInConfig()//errorchecking...conf:=&ConfYaml{}err=viper.Unmarshal(conf)//errorchecking...我的结构是这样的:typeConfY

go - 是否可以将 Go Task runner 配置为使用文件扩展名 yaml?

是否可以配置Go任务运行器(https://taskfile.dev/)以使用文件扩展名为“yaml”而不是“yml”的文件? 最佳答案 任务作者在这里。目前唯一的方法是运行:task--taskfile=Taskfile.yaml或task-tTaskfile.yaml也就是说,有一个openissue和一个openPR关于使.yaml扩展自动工作,因此最终将在没有标志的情况下工作。 关于go-是否可以将GoTaskrunner配置为使用文件扩展名yaml?,我们在StackOverf

c - 如何调用作为参数接收的 C 函数

我想使用在C语言中进行一些调整的Go库。我制作了具有3个参数intx、y和函数类型f的GoAdderGo函数。GoAdder函数将调用f参数。加法器.gopackagemainimport"fmt"import"C"//exportFtesttypeFtestfunc(C.int);//exportGoAdderfuncGoAdder(x,yint,fFtest)int{fmt.Printf("Gosays:adding%vand%v\n",x,y)f(10);returnx+y}funcmain(){}//Requiredbutignored我在上面将gopackage构建为一个名为

c - 如何重新打开一个关闭的文件描述符

我有一个场景,我为两个child和parent之间的通信创建了管道。Parent将(使用写入函数)数据写入管道并关闭相应的文件描述符。问题是当我想再次将数据写入管道时,写入函数返回错误代码-1。我认为这是因为在上一次迭代中已经关闭了写入端。那么对应的文件描述符关闭一次后如何打开。我尝试使用open()函数,该函数需要某些文件的路径作为参数。但是我没有在我的应用程序中使用任何文件。我有简单的文件描述符(intarr[2])。是否可以通过管道实现上述场景???? 最佳答案 一旦管道关闭,它就关闭了。你不能把它带回来。如果您想向其中写入更